<form id="EditSysUser" method="post" novalidate="novalidate" class="form-inline">
	<div class="row">
		<div class="col-lg-6 col-md-6">
			<div class="form-group">
				<label>姓名 :</label>
				<input class="form-control" id="realName" type="text" name="realName" placeholder="姓名" style="width: 160px;" />
			</div>
		</div>
		<div class="col-lg-6 col-md-6">
			<div class="form-group">
				<label>邮箱 :</label>
				<input class="form-control" id="email" type="text" name="email" placeholder="邮箱" style="width: 160px;" />
			</div>
		</div>
		<div class="col-lg-6 col-md-6">
			<div class="form-group">
				<label>电话 :</label>
				<input class="form-control" id="mobile" type="text" name="mobile" placeholder="电话" style="width: 160px;" />
			</div>
		</div>
		<div class="col-lg-6 col-md-6">
			<div class="form-group">
				<label>部门 :</label>
				<select class="form-control" id="deptId" name="deptId" style="width: 160px;">
				</select>
			</div>
		</div>
		<div class="col-lg-6 col-md-6">
			<div class="form-group">
				<label>区/县:</label>
				<select class="form-control" id="areaname" name="countryName" onchange="changearea()" style="width: 160px;">
					<option value="">区/县</option>
				</select>
			</div>
		</div>
		<div class="col-lg-6 col-md-6">
			<div class="form-group">
				<label>分局:</label>
				<select class="form-control" id="branchOfficeId" name="branchOffice" onchange="changeTwon()" style="width: 160px;">
					<option value="">分局</option>
				</select>
			</div>
		</div>
		<div class="col-lg-6 col-md-6">
			<div class="form-group">
				<label>网格:</label>
				<select class="form-control" id="gridId" name="gridName" style="width: 160px;">
					<option value="">网格</option>
				</select>
			</div>
		</div>
		<div class="col-lg-6 col-md-6">
			<div class="form-group">
				<label>角色 :</label>
				<select class="form-control" id="roleIdList" name="roleIdList" style="width: 160px;">
				</select>
			</div>
		</div>
		<div class="col-lg-6 col-md-6">
			<div class="form-group">
				<label>登录名 :</label>
				<input class="form-control" id="username" type="text" name="username" placeholder="登录名" style="width: 160px;" />
			</div>
		</div>
		<div class="col-lg-6 col-md-6">
			<div class="form-group">
				<label>状态 :</label>
				<select class="form-control" id="status" name="status" style="width: 160px;">
					<option value="">状态</option>
					<option value="1">启用</option>
					<option value="2">停用</option>
				</select>
			</div>
		</div>
		<input id="password" type="hidden" name="password"  />
		<input type="hidden" id="userId" name="userId">
		<input type="hidden" name="cityName" />
	</div>
</form>
<script>
	$(function() {
		getDeptdata();
		getRoleAata();
		GetArea();
	})

	////请求部门列表
	function getDeptdata() {
		var json = {
			url: GLOBAL.URL + "/sys/dept/list",
			type: 'get',
			successfn: function(data) {
				setDeptoption(data.page.list);
			},
			errorfn: function() {
				//ajaxUpdataTable();
				//$.ligerDialog.warn("系统繁忙，请稍候再试");
			}
		};
		ajaxdata(json);

	}

	////加载列表数据
	function setDeptoption(data) {
		var listStr = '<option value="">所属部门</option>';
		if(data != null) {
			for(var i = 0; i < data.length; i++) {
				listStr += '<option value="' + data[i].deptId + '">' + data[i].name + '</option>';
			}
		}
		$("#deptId").html(listStr);
	}
	//请求角色
	function getRoleAata() {
		var json = {
			url: GLOBAL.URL + "/sys/role/list",
			type: 'get',
			successfn: function(data) {
				setRole(data.page.list);
			},
			errorfn: function() {
				//ajaxUpdataTable();
				//$.ligerDialog.warn("系统繁忙，请稍候再试");
			}
		};
		ajaxdata(json);

	}

	function setRole(data) {
		var listStr = '<option value="">所属角色</option>';
		if(data != null) {
			for(var i = 0; i < data.length; i++) {
				listStr += '<option value="' + data[i].roleId + '">' + data[i].roleName + '</option>';
			}
		}
		$("#roleIdList").html(listStr);
	}

	//获取区县
	function GetArea() {
		var json = {
			url: GLOBAL.URL + "/guidinfo/getAllAreaList",
			type: 'post',
			data: {
				"queryType": 0
			},
			successfn: function(data) {
				SetArea(data);
			},
			errorfn: function() {
				//ajaxUpdataTable();
				//$.ligerDialog.warn("系统繁忙，请稍候再试");
			}
		};
		ajaxdata(json);
	}

	function SetArea(data) {
		var str = '<option value="">区/县</option>';
		for(var i = 0; i < data.data.length; i++) {
			str += '<option value="' + data.data[i].area + '">' + data.data[i].area + '</option>';
		}
		$("#areaname").html(str);
	}
	//区县点击
	function changearea() {
		if($("#areaname").val() == "") {
			$("#branchOfficeId").html('<option value="">分局</option>');
			$("#gridId").html('<option value="">网格</option>');
		} else {
			GetWork($("#areaname").val());
		}
	}
	//获取分局
	function GetWork(areaname) {
		var json = {
			url: GLOBAL.URL + "/guidinfo/getAllAreaList",
			type: 'post',
			data: {
				"area": areaname,
				"queryType": 1
			},
			successfn: function(data) {
				SetWork(data);
			},
			errorfn: function() {
				//ajaxUpdataTable();
				//$.ligerDialog.warn("系统繁忙，请稍候再试");
			}
		};
		ajaxdata(json);
	}

	function SetWork(data) {
		var str = '<option value="">分局</option>';
		for(var i = 0; i < data.data.length; i++) {
			str += '<option value="' + data.data[i].town + '">' + data.data[i].town + '</option>';
		}
		$("#branchOfficeId").html(str);
	}

	function changeTwon() {
		if($("#areaname").val() == "" || $("#branchOfficeId").val() == "") {
			$("#gridId").html('<option value="">网格</option>');
		} else {
			Getwangge($("#areaname").val(),$("#branchOfficeId").val());
		}
	}
	//获取网格
	function Getwangge(areaname,branchOfficeId) {
		var json = {
			url: GLOBAL.URL + "/guidinfo/getAllAreaList",
			type: 'post',
			data: {
				"area": areaname,
				"town": branchOfficeId,
				"queryType": 2
			},
			successfn: function(data) {
				SetWangge(data);
			},
			errorfn: function() {
				//ajaxUpdataTable();
				//$.ligerDialog.warn("系统繁忙，请稍候再试");
			}
		};
		ajaxdata(json);
	}

	function SetWangge(data) {
		var str = '<option value="">网格</option>';
		for(var i = 0; i < data.data.length; i++) {
			str += '<option value="' + data.data[i].branchOffice + '">' + data.data[i].branchOffice + '</option>';
		}
		$("#gridId").html(str);
	}
</script>